<script type="text/javascript">
function getlist(server)
{	  
  resObjekt.abort();
  resObjekt.open("get","ajax/flightview.ajax.php?server=<?echo $_REQUEST[server]?>",true);
  resObjekt.onreadystatechange=showlist;
  resObjekt.send(null);
}  
function restzeit(sek)
{
  var h=sek/3600;
  if(h>1) 
    return "> "+Math.round(h)+" Stunden";
  else if(sek>100) 
    return "> "+(Math.round(sek/60)+1)+" Minuten";
  else 
    return "> "+sek+" Sekunden";
}
function option(opt, kommander)
{
  resObjekt.abort();
  resObjekt.open("get","ajax/flightview.ajax.php?server=<?echo $_REQUEST[server]?>&option="+opt+"&kommander="+kommander,true);
  resObjekt.onreadystatechange=showlist;
  resObjekt.send(null);
}
function showlist()
{
  var html='<table border="1" cellspacing="0" cellpadding="0" width="90%">';
  html+="<tr>";
  html+="<th>Kommander</th>";
  html+="<th>Auftrag</th>";
  html+="<th>Start</th>";
  html+="<th>Ziel</th>";
  html+="<th>Ankunft</th>";
  html+="<th>Optionen</th>";
  html+="</tr>";
  if(resObjekt.readyState==4)
  {
    var arr=resObjekt.responseText.split("|");
    var i=0;
    while(arr[i])
    {
      var id=arr[i++];
      html+="<tr>";
      html+="<td align=\"center\">"+arr[i++]+"</td>";
      html+="<td align=\"center\">"+arr[i++]+"</td>";
      html+="<td align=\"center\">"+arr[i++]+":"+arr[i++]+"</td>";
      html+="<td align=\"center\">"+arr[i++]+":"+arr[i++]+"</td>";
      rest=restzeit(arr[i++]);
      html+="<td align=\"center\"><span id=\"f"+id+"\">"+rest+"</td>";
      html+="<td width=\"150px\"><nobr>";
      html+="<input type=\"button\" value=\"Flug abbrechen\" onclick=\"option('abbr');\"/>";
      html+="<input type=\"button\" value=\"Ankunft erzwingen\" onclick=\"option('ankunft',"+id+");\"/>";
      html+="</nobr></td>";
      html+="</tr>";
    }
    document.getElementById('list').innerHTML=html;          		  
  }
}
function ref()
{
  getlist(<?echo $_REQUEST[server]?>);
  window.setTimeout("ref()",5000);
}
ref();
</script>

<div>
    <H1>Luftüberwachung</H1>
    <div id="list">
    </div>
</div>
